<template>
  <el-upload
    action=""
    :http-request="onUpload"
  >
    <el-button size="small" type="primary">APP上传</el-button>

  </el-upload>
  <el-upload
    action=""
    :http-request="onUpload_1"
  >

    <el-button size="small" type="primary">安全帽上传</el-button>
  </el-upload>

</template>
<script>
import {uploadFile} from "@/api/monitor/upload";

export default {
  name:'index',
  data(){
    return{

    }
  },
  methods: {
// 上传文件
    onUpload (file) {
      let formData = new FormData();
      formData.append('file',file.file);
      formData.append('type',"app");
      uploadFile(formData).then((res) => {
        console.log('12580',res);
        this.$modal.msgSuccess('UPLOAD_SUCCESS')
      }).catch((e) => {
        this.$message.error(e.message)
      })
    },
    onUpload_1 (file) {
      let formData = new FormData();
      formData.append('file',file.file);
      formData.append('type',"helmet");
      uploadFile(formData).then((res) => {
        console.log('12580',res);
        this.$modal.msgSuccess('UPLOAD_SUCCESS')
      }).catch((e) => {
        this.$message.error(e.message)
      })
    },
  }
}
</script>
